home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Pound defines
- Date: 19 Jan 1996 22:27:33 GMT
- Organization: OpenVision
- Message-ID: <4dp5sl$9t8@spanky.pls.ov.com>
- References: <4dgquf$fuq@bmerhc5e.bnr.ca>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article fuq@bmerhc5e.bnr.ca, studnt1@bmerhe78.bnr.ca (Jean Giblin ) writes:
- >hello everyone:
- >
- > I was wondering if anybody out there knows about a C command that prints the
- >the name of the define when given the number. Example:
- >
- > #define MAX 20
- >
- >when given 20 it will return max.
- >
- >I thought a command existed, but I could be wrong. Please respond to this newgroup,
- >and not my e-mail address.
- >
- > Thanks
- > Nick
-
-
- All of the directives that start with # are C pre-processor directives. These
- directives are all resolved before compiling begins. This means for your
- example that all references to MAX are replaced with 20. To see what I mean,
- see if your compiler will output the actual source after pre-processing.
- On most UNIX compilers the command is "cc -E filename.c"
-
- Given that the defines disappear before compiling, there is no way to work
- backwards from the value. Besides, how would one handle the following?
-
- #define FOO 20
- #define BAR 20
- #define BLECH 20
-
- Fletcher.Glenn@ov.com
-
-
-